﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Tour.Linq.TourDBML;

public partial class AdminManager_Admin_AdminManager : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DisplayInfo();
        }
    }

    private void DisplayInfo()
    {
        AdminListView.DataSource = from a in TourContext.Admin
                                   orderby a.AddTime descending
                                   select a;
        Page.DataBind();

    }

    protected void ListItemCommand(object sender, ListViewCommandEventArgs e)
    {
        if (e.CommandName == "DeleteItem")
        {
            Admin admin = TourContext.Admin.First(a => a.ID == e.CommandArgument.ToInt());
            if (admin != null)
            {
                TourContext.Admin.DeleteOnSubmit(admin);
                TourContext.SubmitChanges();
                _Message = "删除用户成功";

            }
        }
        DisplayInfo();
    }


}
